package com.ruoyi.system.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.FormColumnMapper;
import com.ruoyi.system.domain.FormColumn;
import com.ruoyi.system.service.IFormColumnService;

/**
 * 单字段Service业务层处理
 *
 * @author ruoyi
 * @date 2023-11-16
 */
@Service
public class FormColumnServiceImpl extends ServiceImpl<FormColumnMapper,FormColumn> implements IFormColumnService
{
    @Autowired
    private FormColumnMapper formColumnMapper;


   @Override
    public  List<FormColumn>  listColumnList(Long defineId)
    {
        LambdaQueryWrapper<FormColumn> lambdaQueryWrapper =new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(FormColumn::getDefineId,defineId)
                .eq(FormColumn::getShowInList,1)
                .orderByAsc(FormColumn::getListColumnSort);
        List<FormColumn> list = this.list(lambdaQueryWrapper);
        return list;
    }

    /**
     * 查询单字段
     *
     * @param id 单字段主键
     * @return 单字段
     */
    @Override
    public FormColumn selectFormColumnById(Long id)
    {
        return formColumnMapper.selectFormColumnById(id);
    }

    /**
     * 查询单字段列表
     *
     * @param formColumn 单字段
     * @return 单字段
     */
    @Override
    public List<FormColumn> selectFormColumnList(FormColumn formColumn)
    {
        return formColumnMapper.selectFormColumnList(formColumn);
    }

    /**
     * 新增单字段
     *
     * @param formColumn 单字段
     * @return 结果
     */
    @Override
    public int insertFormColumn(FormColumn formColumn)
    {
        formColumn.setCreateTime(DateUtils.getNowDate());
        return formColumnMapper.insertFormColumn(formColumn);
    }

    /**
     * 修改单字段
     *
     * @param formColumn 单字段
     * @return 结果
     */
    @Override
    public int updateFormColumn(FormColumn formColumn)
    {
        formColumn.setUpdateTime(DateUtils.getNowDate());
        return formColumnMapper.updateFormColumn(formColumn);
    }

    /**
     * 批量删除单字段
     *
     * @param ids 需要删除的单字段主键
     * @return 结果
     */
    @Override
    public int deleteFormColumnByIds(Long[] ids)
    {
        return formColumnMapper.deleteFormColumnByIds(ids);
    }

    /**
     * 删除单字段信息
     *
     * @param id 单字段主键
     * @return 结果
     */
    @Override
    public int deleteFormColumnById(Long id)
    {
        return formColumnMapper.deleteFormColumnById(id);
    }
}
